<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title> - 金币发放</title>
	    <meta name="keywords" content="">
	    <meta name="description" content="">
	    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	    <link href="__STATIC__/css/font-awesome.css?v=4.4.0" rel="stylesheet">
	    <link href="__STATIC__/css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
	    <link href="__STATIC__/css/animate.css" rel="stylesheet">
	    <link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
	    <link href="__STATIC__/css/new_file.css" rel="stylesheet">
	</head>
	<body class="gray-bg">
		<div class="wrapper wrapper-content  animated fadeInRight">
			<div class="row">
				<div class="col-sm-12">
					<div class="ibox ">
						<div class="ibox-title">
							<h5>金币发放</h5>
						</div>
						<div class="toogl_body">
	                    	<a href="Club.html"><button type="button" class="btn btn-w-m btn-bt btn-white">亲友圈管理</button></a>
	                    	<a href="Club_configure.html"><button type="button" class="btn btn-w-m btn-white btn-bt">钻石配置</button></a>
	                    	<a href="Club_establish.html"><button type="button" class="btn btn-w-m btn-white btn-bt">创建亲友圈</button></a>
	                    	<a href="Club_goldcoin.html"><button type="button" class="btn btn-w-m btn-white btn-bt">金币配置</button></a>
	                    	<a href="Club_grant.html"><button type="button" class="btn btn-w-m btn-info btn-bt">金币发放</button></a>
	                    	<a href="Club_conf.html"><button type="button" class="btn btn-w-m btn-white btn-bt">亲友圈配置</button></a>
							<a href="Club_from.html"><button type="button" class="btn btn-w-m btn-white btn-bt">房间配置</button></a>
	                    	<hr style="clear: both;"/>

							<div class="ibox-content ibox-jqGrid">
								<div class="form-group mmp-gbl">
	                                <label class="col-sm-2 control-dy">亲友圈ID：</label>
	                                <div class="col-sm-8 form-time1">
	                                    <input type="text" placeholder="请输入亲友圈ID" class="form-control form-time-bk" id="cid">
	                                </div>
	                                <label class="col-sm-2 control-dy">亲友圈名称：</label>
	                                <div class="col-sm-8 form-time1">
	                                    <input type="text" placeholder="请输入亲友圈名称" class="form-control " readonly="readonly" id="club_name">
	                                </div>
	                                <label class="col-sm-2 control-dy">会长昵称：</label>
	                                <div class="col-sm-8 form-time1">
	                                    <input type="text" placeholder="请输入会长昵称" class="form-control " readonly="readonly" id="president_name"> 
	                                </div>
	                                <label class="col-sm-2 control-dy">金币库存：</label>
	                                <div class="col-sm-8 form-time1">
	                                    <input type="text" placeholder="请输入金币库存" class="form-control" readonly="readonly" id="club_gold"> 
	                                </div>
	                                <label class="col-sm-2 control-dy">金币数量：</label>
	                                <div class="col-sm-8 form-time1">
	                                    <input type="text" placeholder="请输入金币数量" class="form-control form-time-bk" id="Club_gold_issued"> 
	                                </div>
	                                <button type="button" class="btn btn-w-m btn-info" onclick="Club_gold_issued()">确认</button>
	                            </div>
		                        <div class="jqGrid_wrapper">
                                <div class="form-group"><br/>
                                    <label class="col-sm-2 control-dy">查询时间：</label>
                                    <div class="col-sm-8 form-time1">
                                        <input id="time1" class="form-control form-con-ban layer-date">
                                        <!--<label class="test-item">-</label>-->
                                        <!--<input id="time2" class="form-control form-con-ban layer-date">-->
                                       <!--  <input type="text" placeholder="请输入查询时间段" class="form-control form-time-bk" id="time1" readonly="readonly"> 
                                        <span class="help-block m-b-none">请输入查询时间段</span> -->
                                    </div>
                                    <button type="button" id="buttonid" class="btn btn-w-m btn-info">查询</button>
                                </div>
		                            <table id="table_list_1"></table>
		                            <div id="pager_list_1"></div>
		                        </div>
		                    </div>
						</div>
					</div>
				</div>
			</div>
		</div>
		
	    <script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
	    <script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
	    <script src="__STATIC__/js/plugins/peity/jquery.peity.min.js"></script>
	    <script src="__STATIC__/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
	    <script src="__STATIC__/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>
	    <script src="__STATIC__/js/content.js?v=1.0.0"></script>
    	<script src="__STATIC__/js/plugins/laydate/laydate.js"></script>
		<script>
        var i = 0;
            var mydata = [];

            $(function() {
                var dateArray = [];
                var myDate = new Date(); //获取今天日期
                myDate.setDate(myDate.getDate() - 7);
                var dateTemp;
                var flag = 1;
                for(var i = 0; i < 8; i++) {
                    var Month = (myDate.getMonth() + 1) < 10 ? "0" + (myDate.getMonth() + 1) : (myDate.getMonth() + 1);
                    //                  console.log(Month);
                    var mydate = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate();
                    //                  console.log(mydate);
                    dateTemp = myDate.getFullYear() + "-" + Month + "-" + mydate;
                    dateArray.push(dateTemp);
                    myDate.setDate(myDate.getDate() + flag);
                };
                // $("#time1").val(dateArray[0]);
                // $("#time2").val(dateArray[6]);
                // _inquireClick()
            })
        //根据会长id改变 改变会长名
        $("#cid").blur(function(){
             var cid = $('#cid').val();
			// $("#club_gold").val("");
             // if(cid ==""){
             //    alert("请输入会长id");
             //    return false;
             // }
             $.ajax({
                    type: "post",
                    url: "__URL__/Club_gold_number",
                    data: {
                        'cid':cid,
                    },
                    dataType: "json",
                    success: function(e) {
                        console.log(e);
                        if( e == null){
                            alert("没有该亲友圈");
                            return false;
                        }else{
                            $('#club_name').val(e.club_name);
                            $('#president_name').val(e.president_name);
                            $('#club_gold').val(e.club_gold);
                            // console.log(e);
                        }
                        
                    },
                    error: function(e) {
                        console.log(e);
                        // alert(e.msg);
                    }
                });
        });
        //解散亲友圈
        function Club_gold_issued(){
                var id = $('#cid').val();
                var club_gold = $('#Club_gold_issued').val();
                var club_name = $('#club_name').val();
                if(id ==""){
                alert("请输入会长id");
                return false;
                }
                $.ajax({
                    type: "post",
                    url: "__URL__/Club_gold_issued",
                    data: {
                        'cid':id,
                        'club_gold':club_gold,
                        'club_name':club_name,
                    },
                    dataType: "json",
                    success: function(e) {
                        // console.log(e);
                        alert(e.msg);
                        location.reload();
                    },
                    error: function(e) {
                        // console.log(e);
                        alert(e.msg);
                    }
                });
        }
        $('#buttonid').on('click', function() {     //页面上的button按钮的click事件，重新获取参数后发送参数，然后重新加载数据。
                var time = $("#time1").val();
                // var end_time = $("#time2").val();
				var start_time = time.substring(0,10)+" "+"00:00:00";
				var end_time = time.substring(13)+" "+"23:59:59";
                $("#table_list_1").jqGrid('setGridParam',{
                    url:'__URL__/gold_issued_record',
                    datatype:'json',
                    postData:{'start_time':start_time,'end_time':end_time}, //发送数据
                    page:1
                }).trigger("reloadGrid"); //重新载入
        });
        $(document).ready(function () {
        	var start_time = $("#time1").val();
            var end_time = $("#time2").val();
            $.jgrid.defaults.styleUI = 'Bootstrap';

            $("#table_list_1").jqGrid({
                url:'__URL__/gold_issued_record',
                postData:{'start_time':start_time,'end_time':end_time},
                datatype: "json",
                mtype: 'POST',
                height: 450,
                autowidth: true,
                shrinkToFit: true,
                rowNum: 20,
                rowList: [20,50,100],
                colNames: ['操作时间', '操作人', '亲友圈ID', '亲友圈名称', '发放金币数量'],
                colModel: [
                    {
                        name: 'opera_time',
                        index: 'opera_time',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center'
                    },
                    {
                        name: 'opera_pepole',
                        index: 'opera_pepole',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center'
                    },
                    {
                        name: 'club_id',
                        index: 'club_id',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center'
                    },
                    {
                        name: 'club_name',
                        index: 'club_name',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center'
                    },
                    {
                        name: 'number_gold',
                        index: 'number_gold',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        align:'center'
                    }
                ],
                pager: "#pager_list_1",
                viewrecords: true,
                loadonce: true,
                caption: "金币发放",
                hidegrid: false
            });
            $("#jd").hide();
            $(function(){
            	$("#jd").click(function(){
            		$("#jd").hide();
            		$("#dj").show();
            	});
            	$("#dj").click(function(){
            		$("#dj").hide();
            		$("#jd").show();
            	});
            });
            $("#fj").hide();
            $(function(){
            	$("#fj").click(function(){
            		$("#fj").hide();
            		$("#jj").show();
            	});
            	$("#jj").click(function(){
            		$("#jj").hide();
            		$("#fj").show();
            	});
            });
            $('.form-conselein').hide();
			$('.form-consele').on('change',function(){
				if ($('.form-consele').val() == '0') {
					$('.form-conselein').hide();
				} else{
					$('.form-conselein').show();
				}
			})
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_list_1').setGridWidth(width);
            });
		    laydate.render({
		      elem: '#time1'
        //       ,type: 'datetime'
		      ,range: true
		    });
		    laydate.render({
		      elem: '#time2'
        //       ,type: 'datetime'
		      // ,range: true
		    });
        });
    </script>


	</body>

</html>